<!DOCTYPE html>
<html lang="en">
    
<head>
    <title>Matrix Admin</title><meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/bootstrap-responsive.min.css" />
    <link rel="stylesheet" href="css/matrix-login.css" />
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="http://localhost:8080/static/login/css/simpleAlert.css">


    <style type="text/css">
        input{
            font-family: "Microsoft Yahei";
        }
        .control-label{
            color: #B2DFEE;
            padding-left: 4px;
        }

        #btnSendCode hover{
            background: #28b770;
        }
    </style>


</head>
<body onkeydown="keydown()">
    <div id="loginbox">  
        <div class="control-group normal_text"> 
            <h2 style="color:#B2DFEE;font-size:28px;">信息管理系统平台</h2>
            <span style="font-size:14px;color:gray;">版权所有  @塔里木大学洗浴中心 2017-2018</span>
        </div>          
        <form id="loginform" class="form-vertical" action="http://themedesigner.in/demo/matrix-admin/index.html">
            <div class="control-group">
                <label class="control-label">登陆账号</label>
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_lg" ><i class="icon-user" style="font-size:16px;"></i></span><input id="user" type="text" value="admin" />
                    </div>
                </div>
            </div>
            <div class="control-group2">
                <label class="control-label">登陆密码</label>
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_ly" ><i class="icon-lock" style="font-size:16px;"></i></span><input id="passwd"  type="password" />
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <span class="pull-left"><a class="flip-link btn btn-info" id="to-recover">注册账户？</a></span>
                <span class="pull-right"><input type="button" id="checkBtn"  class="btn btn-success" style="width:335px;" value=" 登&nbsp;&nbsp;&nbsp;&nbsp;录"/></span>
            </div>
            <div class="control-group normal_text">
                <div style="font-size:14px;color:gray;">推荐使用webkit内核浏览器，如chrome等</div>
            </div>
        </form>
        

        <form id="recoverform" action="#" class="form-vertical" style="padding-top:10px;">
            <label class="control-label">登陆工号</label>
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lg"><i class="icon-user" style="font-size:16px;"></i></span><input id="gonghao" type="text" name="re_username" />
                </div>
            </div>

            <label class="control-label">邮箱</label>
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lg"><i class="icon-user" style="font-size:16px;"></i></span><input id="re_mail1" type="text" name="re_mail" />

                </div>

            </div>
            <label class="control-label">邮箱验证码</label>
            <div class="controls">
                <div class="main_input_box">
                    <input id="yanzheng" style="width: 320px" type="text"  /> <span class="add-on bg_lg" id="btnSendCode" style="width: 85px" onclick="sendMessage()">发送验证码</span>
                    <!--<a id="btnSendCode1" type="button" onclick="sends.send();">发送验证码</a>-->
                </div>
            </div>

            <label class="control-label">电话</label>
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lg"><i class="icon-user" style="font-size:16px;"></i></span><input id="dianhua" type="text" name="re_phone" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">登录密码</label>
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_ly"><i class="icon-lock" style="font-size:16px;"></i></span><input id="mima" type="password" name="re_password"/>
                    </div>
                </div>
            </div>
            <div class="control-group" style="padding-top:0px;">
                <label class="control-label">确认密码</label>
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_ly"><i class="icon-lock" style="font-size:16px;"></i></span><input id="mima1" type="password" name="re_confirmpassword" />
                    </div>
                </div>
            </div>


          <!--  <input id="btnSendCode" type="button" value="获取验证码" onClick="sendMessage()"/>-->
            <div class="form-actions">
                <span class="pull-left"><a href="#" class="flip-link btn btn-success" id="to-login">&laquo; 返回登录</a></span>
                <span class="pull-right" id="changePwd"><a  class="btn btn-info" style="width:310px;">注册账户</a></span>
            </div>
            <div class="control-group normal_text">
                <div style="font-size:14px;color:gray;">推荐使用webkit内核浏览器，如chrome等</div>
            </div>
        </form>

    </div>


    <script type="text/javascript" src="/static/fm/jquery/jquery-1.7.2.min.js"></script>
    <script src="js/matrix.login.js"></script>
    <script src="/static/login/js/jquery.min.js"></script>
    <script src="/static/login/js/simpleAlert.js"></script>
    <script type="text/javascript">
        var InterValObj; //timer变量，控制时间
        var count = 30; //间隔函数，1秒执行
        var curCount;//当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6;//验证码长度
        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var reMail=$("#re_mail1").val();
            alert("邮箱值"+reMail);
            var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
            if(!reg.test(reMail)){
                alert("邮箱格式错误！")
            }else {
                alert("邮箱格式正确！")

//http://localhost:8080/adminlogin/mail
               //向后台发送处理数据
                $.ajax({
                    type: "post", //用POST方式传输
                    url: 'http://localhost:8080/adminlogin/mailn', //目标地址
                    data: {"mailNo":$("#re_mail1").val()},
                    dataType: "json", //数据格式:JSON


                });

               //设置button效果，开始计时
                $("#btnSendCode").attr("disabled", "true");
                $("#btnSendCode").html( + curCount + "秒再获取");
                InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次



            }

        }
        //timer处理函数
        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj);//停止计时器
                $("#btnSendCode").removeAttr("disabled");//启用按钮
                $("#btnSendCode").html("重新发送验证码");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效
            }
            else {
                curCount--;
                $("#btnSendCode").html( + curCount + "秒再获取");
            }
        }
    </script>


    <script type="text/javascript">
        $("#changePwd").click(function(e){ // 注意，括号里必须有个自定义的变量，可以是e或者其他


            var gonghao=$("#gonghao").val();
            var youxianghao=$("#re_mail1").val();
            var yanzheng=$("#yanzheng").val();
            var dianhua=$("#dianhua").val();
            var pass=$("#mima").val();
            var pass1=$("#mima1").val();
            alert(gonghao+youxianghao+yanzheng+dianhua+pass+pass1);
            if(pass != pass1){
                var dblChoseAlert = simpleAlert({
                    "content":"两次密码不同请重新输入!",
                    "buttons":{
                        "确定":function () {

                            dblChoseAlert.close();
                        }
                    }
                })
            }else{
                alert(gonghao+youxianghao+yanzheng+dianhua+pass+pass1+"什么");
                $.ajax({
                    /*?userName="+name+"&"+"passwd="+pass*/
                    type: "get",
                    url: "http://localhost:8080/adminlogin/registe",
                    data: {"gonghao":gonghao,
                           "youxianghao":youxianghao,
                           "dianhua":dianhua,
                           "yanzheng":yanzheng,
                            "pass":pass},

                    /*        data: {"userName":$("#signin-username1").val(), "passwd":$("#signin-password1").val()},*/
                    dataType: "json",

                    success: function(data,statusTxt,xhr){
                        if(statusTxt == "success"){
                            alert("1111111");
                            var userData = eval(data);
                            if(userData.code=="F_000000"){

                                var dblChoseAlert = simpleAlert({
                                    "content":"注册成功!",
                                    "buttons":{
                                        "确定":function () {
                                            dblChoseAlert.close();

                                        }
                                    }
                                })
                            }else{
                                if(userData.code=="F_99991"){
                                    var dblChoseAlert = simpleAlert({
                                        "content":"验证码错误!",
                                        "buttons":{
                                            "确定":function () {

                                                dblChoseAlert.close();
                                            }
                                        }
                                    })
                                }else{
                                    var dblChoseAlert = simpleAlert({
                                        "content":"注册失败,同一卡号只能注册一次!",
                                        "buttons":{
                                            "确定":function () {

                                                dblChoseAlert.close();
                                            }
                                        }
                                    })

                                }

                            }
                        }

                    },
                    error:function(xhr,textStatus){
                        var dblChoseAlert = simpleAlert({
                            "content":"注册失败!",
                            "buttons":{
                                "确定":function () {

                                    dblChoseAlert.close();
                                }
                            }
                        })
                        console.log('错误')
                        console.log(xhr)
                        console.log(textStatus)
                    },
                    complete:function(){
                        console.log('结束')
                    }
                });

            }

            //  }
            /*         }
                 },
             });*/
            /* e.stopPropagation(); // 阻止冒泡*/

        });


    </script>




    <script>

        $(function () {

            $("#checkBtn").on("click",function () {
        /*        if($.cookie('adminName') !=null || $.cookie('adminName') == null){
                    alert("年后");
                    $.cookie('adminName', null);
                    alert($.cookie('adminName')+"cookie")
                }
                alert("年前");
                $.cookie('adminName', $("#user").val(), {
                    expires : 1//过期时间，1 天后
                });*/



                $.ajax({
                    type: "post",
                    url: "http://localhost:8080/adminlogin/showUser",
                    data: {"userName":$("#user").val(), "passwd":$("#passwd").val()},
                    dataType: "json",
                    success: function(data,statusTxt,xhr){
                         if(statusTxt=="success"){

                                alert("1111"+$("#user").val());
                                localStorage.removeItem("key");
                                localStorage.setItem('key', JSON.stringify($("#user").val()));
                                window.location.href="http://localhost:8080/static/moban1/index.html";
                        }else{
                            var dblChoseAlert = simpleAlert({
                                "content":"登录失败!",
                                "buttons":{
                                    "确定":function () {

                                        dblChoseAlert.close();
                                    }
                                }
                            })

                        }


                    },
                    error:function(xhr,textStatus){
                        var dblChoseAlert = simpleAlert({
                            "content":"登录失败!",
                            "buttons":{
                                "确定":function () {

                                    dblChoseAlert.close();
                                }
                            }
                        })
                        console.log('错误')
                        console.log(xhr)
                        console.log(textStatus)
                    },
                    complete:function(){
                        console.log('结束')
                    }
               });
            });
           /* //alert("111");
            if(statusTxt1=="success"){
                window.location.href="http://localhost:8080/static/moban1/index.html";
            }
           //*/
        });
        /*function2();*/

    </script>
</body>

</html>
